1
2
3
4 package joeq.Runtime;
5
6 import joeq.Class.PrimordialClassLoader;
7 import joeq.Class.jq_Class;
8 import joeq.Class.jq_StaticMethod;
9 import joeq.Memory.Address;
10 import joeq.Memory.CodeAddress;
11 import joeq.Memory.StackAddress;
12 import joeq.Scheduler.jq_Thread;
13
14 /***
15 * @author John Whaley <jwhaley@alum.mit.edu>
16 * @version $Id: Unsafe.java 1457 2004-03-09 22:38:33Z jwhaley $
17 */
18 public abstract class Unsafe {
19
20 public static final native int floatToIntBits(float i);
21 public static final native float intBitsToFloat(int i);
22 public static final native long doubleToLongBits(double i);
23 public static final native double longBitsToDouble(long i);
24 public static final native void pushArg(int arg);
25 public static final native void pushArgA(Address arg);
26 public static final native float popFP32();
27 public static final native double popFP64();
28 public static final native void pushFP32(float v);
29 public static final native void pushFP64(double v);
30 public static final native long invoke(CodeAddress address) throws Throwable;
31 public static final native Address invokeA(CodeAddress address) throws Throwable;
32 public static final native int EAX();
33 public static final native jq_Thread getThreadBlock();
34 public static final native void setThreadBlock(jq_Thread t);
35 public static final native void longJump(CodeAddress ip, StackAddress fp, StackAddress sp, int eax);
36
37
38
39
40
41
42
43
44 public static final native boolean isEQ();
45 public static final native boolean isGE();
46
47 public static final jq_Class _class;
48 public static final jq_StaticMethod _floatToIntBits;
49 public static final jq_StaticMethod _intBitsToFloat;
50 public static final jq_StaticMethod _doubleToLongBits;
51 public static final jq_StaticMethod _longBitsToDouble;
52 public static final jq_StaticMethod _pushArg;
53 public static final jq_StaticMethod _pushArgA;
54 public static final jq_StaticMethod _popFP32;
55 public static final jq_StaticMethod _popFP64;
56 public static final jq_StaticMethod _pushFP32;
57 public static final jq_StaticMethod _pushFP64;
58 public static final jq_StaticMethod _invoke;
59 public static final jq_StaticMethod _invokeA;
60 public static final jq_StaticMethod _EAX;
61 public static final jq_StaticMethod _getThreadBlock;
62 public static final jq_StaticMethod _setThreadBlock;
63 public static final jq_StaticMethod _longJump;
64 public static final jq_StaticMethod _isEQ;
65 public static final jq_StaticMethod _isGE;
66
67 static {
68 _class = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljoeq/Runtime/Unsafe;");
69 _floatToIntBits = _class.getOrCreateStaticMethod("floatToIntBits", "(F)I");
70 _intBitsToFloat = _class.getOrCreateStaticMethod("intBitsToFloat", "(I)F");
71 _doubleToLongBits = _class.getOrCreateStaticMethod("doubleToLongBits", "(D)J");
72 _longBitsToDouble = _class.getOrCreateStaticMethod("longBitsToDouble", "(J)D");
73 _pushArg = _class.getOrCreateStaticMethod("pushArg", "(I)V");
74 _pushArgA = _class.getOrCreateStaticMethod("pushArgA", "(Ljoeq/Memory/Address;)V");
75 _popFP32 = _class.getOrCreateStaticMethod("popFP32", "()F");
76 _popFP64 = _class.getOrCreateStaticMethod("popFP64", "()D");
77 _pushFP32 = _class.getOrCreateStaticMethod("pushFP32", "(F)V");
78 _pushFP64 = _class.getOrCreateStaticMethod("pushFP64", "(D)V");
79 _invoke = _class.getOrCreateStaticMethod("invoke", "(Ljoeq/Memory/CodeAddress;)J");
80 _invokeA = _class.getOrCreateStaticMethod("invokeA", "(Ljoeq/Memory/CodeAddress;)Ljoeq/Memory/Address;");
81 _EAX = _class.getOrCreateStaticMethod("EAX", "()I");
82 _getThreadBlock = _class.getOrCreateStaticMethod("getThreadBlock", "()Ljoeq/Scheduler/jq_Thread;");
83 _setThreadBlock = _class.getOrCreateStaticMethod("setThreadBlock", "(Ljoeq/Scheduler/jq_Thread;)V");
84 _longJump = _class.getOrCreateStaticMethod("longJump", "(Ljoeq/Memory/CodeAddress;Ljoeq/Memory/StackAddress;Ljoeq/Memory/StackAddress;I)V");
85 _isEQ = _class.getOrCreateStaticMethod("isEQ", "()Z");
86 _isGE = _class.getOrCreateStaticMethod("isGE", "()Z");
87 }
88
89 }